/**
 * Copyright (c) 2009 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.core.wicket.page.paging;

import com.eelpo.cmmp.core.wicket.page.basic.DeniedPage;
import com.eelpo.cmmp.core.wicket.panel.paging.DynamicPagingSortableDataProvider;
import com.eelpo.cmmp.core.wicket.panel.paging.IDynamicPaing;
import com.eelpo.cmmp.core.wicket.panel.paging.ISort;

import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

/**
 * 动态分页基类
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public abstract class DynamicPagingWebPage<T extends ISort> extends DeniedPage implements IDynamicPaing<T> {

	/**
	 * 查询参数对象
	 */
	protected T parameter;

	/**
	 * 数据提供者定义
	 */
	protected SortableDataProvider<T> dataProvider;

	public DynamicPagingWebPage(T parameter) {

		this.parameter = parameter;

		this.dataProvider = new DynamicPagingSortableDataProvider<T>(this, parameter);
	}

	/**
	 * getter方法
	 * 
	 * @return 返回数据提供者
	 */
	public SortableDataProvider<T> getDataProvider() {
		return dataProvider;
	}

	/**
	 * setter方法
	 * 
	 * @param dataProvider
	 *            设置数据提供者
	 */
	public void setDataProvider(SortableDataProvider<T> dataProvider) {
		this.dataProvider = dataProvider;
	}

	/**
	 * getter方法
	 * 
	 * @return 返回查询参数对象
	 */
	public T getParameter() {
		return parameter;
	}

	/**
	 * setter方法
	 * 
	 * @param parameter
	 *            设置查询参数对象
	 */
	public void setParameter(T parameter) {
		this.parameter = parameter;
	}

	/**
	 * 列表绑定数据
	 */
	@Override
	public IModel<T> model(T obj) {
		return new Model<T>(obj);
	}

}